#define _CRT_SECURE_NO_WARNINGS 1

//https://leetcode.cn/problems/valid-sudoku/

class Solution {
    bool checkRow[9][10], checkCol[9][10], checkGrid[3][3][10];
    bool ret = false;
public:
    bool isValidSudoku(vector<vector<char>>& board) {
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                if (board[i][j] != '.')
                {
                    int num = board[i][j] - '0';
                    if (checkRow[i][num] || checkCol[j][num] || checkGrid[i / 3][j / 3][num])
                        return false;

                    checkRow[i][num] = checkCol[j][num] = checkGrid[i / 3][j / 3][num] = true;
                }
            }
        }
        return true;
    }

};